﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using AdventureWorksApp.Web;

namespace AdventureWorksApp.Views
{
    public partial class EmployeeRegistrationWindow : ChildWindow
    {

        public Employee NewEmployee { get; set; }
        public bool TheEnd = false;

        public EmployeeRegistrationWindow()
        {
            InitializeComponent();
            NewEmployee = new Employee();
            addEmployeeDataForm.CurrentItem = NewEmployee;
            addEmployeeDataForm.BeginEdit();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            bool bCommit = addEmployeeDataForm.CommitEdit();
            if (bCommit == false)
                return;
            TheEnd = true;
            this.DialogResult = true;            
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            NewEmployee = null;
            addEmployeeDataForm.CancelEdit();
            TheEnd = true;
            this.DialogResult = false;            
        }

        private void ChildWindow_Closed(object sender, EventArgs e)
        {
        }
    }
}

